<template>
  <div class="uploadList">
    <el-table :data="tableList" stripe border class="user-table" :height="tableHeight"   @selection-change="handleSelectionChange" style="width: 100%;" v-loading="loading">
      <el-table-column type="selection"   width="55"></el-table-column>
      <el-table-column fixed type="index" label="序号" sortable min-width="30"></el-table-column>
      <el-table-column fixed  prop="reproduce" label="类型" min-width="80" align="center">
          <template slot-scope="scope">
              <span v-html="scope.row.reproduce ===1?'<span style=\'color:red;font-weight:bolder;padding:5px;background:yellow\'>返工</span>':'正常'" ></span>
          </template>

      </el-table-column>
      <el-table-column prop="taskNo" label="任务单号" sortable width="100"></el-table-column>
      <el-table-column prop="code29" label="29所编码" sortable width="100"></el-table-column>
      <el-table-column prop="taskSerialNo" label="任务流水号" sortable width="100"></el-table-column>
      <el-table-column prop="planAttribute" label="计划属性" sortable width="100"></el-table-column>
      <el-table-column prop="priority" label="优先级" sortable min-width="100" > </el-table-column>
      <el-table-column prop="wbPlanFinsihDate" label="外包计划完成时间" sortable width="100" :formatter="timeFormatter"></el-table-column>
      <el-table-column prop="nums" label="件数" sortable width="60"></el-table-column>
      <el-table-column prop="makeNo" label="生产令号" sortable min-width="200"></el-table-column>
      <el-table-column prop="drawName" label="图纸名称" sortable min-width="120"></el-table-column>
      <el-table-column prop="drawNums" label="项目图纸张数"  width="50"  align="center"></el-table-column>
      <el-table-column prop="drawCode" label="图纸编号" sortable min-width="120"></el-table-column>
      <el-table-column prop="processStateDesc" label="工序状态" width="120"   align="center"></el-table-column>
     <!--  <el-table-column prop="importerName" label="导入人" sortable width="100"></el-table-column>
      <el-table-column prop="importDate" label="导入时间" sortable min-width="100" :formatter="timeFormatter"></el-table-column> -->
      <el-table-column fixed="right" label="操作" align="center" min-width="170">
        <template slot-scope="scope">
          <slot  :row="scope.row"></slot>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="pagination.currentPage" :page-sizes="[10, 15,20, 25,30,50, 100]" :page-size="pagination.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="pagination.total"></el-pagination>
  </div>
</template>
<script>
import productionApi from 'plugins/axios/productionApi.js';
export default {
  name: 'productionPlanList',
  props:{
    postData:{
      type:Object
    }
  },
  data (){
    return {
      loading:false,
      tableList:[],
      pagination:{/**分页参数 */
        currentPage:1,
        pageSize:10,
        total:0
      },
      processDetailIds:[],
    }
  },
  watch:{
    
  },
  created(){

  },
   computed:{
    tableHeight(){
      return this.$store.state.clientHeight-184;
    }
  },
  methods:{
    /**时间格式化 */
    timeFormatter(row, column, cellValue, index){
      return cellValue?this.timestampToTime(cellValue,'yyyy-mm-dd'):'';
    },
    get29TableList(){
      let self = this;
      self.loading = true;
      let obj = {
        drawCode:self.postData.drawCode,
        makeNo:self.postData.makeNo,
        code:self.postData.code,
        currentPage:self.pagination.currentPage,
        pageSize:self.pagination.pageSize,
        processName:self.postData.name,
        state:self.postData.state,
        processDetailState:self.postData.processDetailState,
        planStatus:self.postData.planStatus,
        taskNo:self.postData.taskNo,
        customer:self.postData.customer,
        code29:self.postData.code29,
        taskSerialNo:self.postData.taskSerialNo,
        needMpwx:0,
        startDate:self.postData.startDate,
        endDate:self.postData.endDate,
      }
      productionApi.productionTaskListA(obj).then(res=>{
        self.loading = false;
        self.tableList= res.content.records;
        self.pagination.total =res.content.total;
      },error=>{
        self.loading = false;
      })
    },
    handleSizeChange(size){/**切换分页条数 */
      this.pagination.pageSize=size;
      this.pagination.currentPage=1;
      this.get29TableList();
    },
    handleCurrentChange(current){/**切换分页页数 */
      this.pagination.currentPage=current;
      this.get29TableList();
    },
    handleSelectionChange(val) {
      this.processDetailIds = [];
        if(val!=null && val!=undefined ){
            val.forEach(element => {
              if(element.processState==='1'){
                this.processDetailIds.push(element.processDetailId); 
              }
            });
        }
        this.$emit('selectedData',this.processDetailIds.join(','));
    }
  }
}
</script>
<style lang="stylus" scoped>

</style>